<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>删除节点</title>
    <script>
        function f1(){
            let u = document.getElementById("u");
            let i2 = document.getElementById("i2");
            // 删除ul中自定义的某一个子节点
            u.removeChild(i2);
        }
        function f2(){
            let u = document.getElementById("u");
            // 删除整个ul
            u.remove();
        }
    </script>
</head>
<body>
<button onclick="f1()">删除子节点</button>
<button onclick="f2()">删除整个节点</button>
<ul id="u">
    <li>item1</li>
    <li id="i2">item2</li>
    <li>item3</li>
</ul>
</body>
</html>